package com.mmm.order.controller;

import com.mmm.common.vo.Paging;
import com.mmm.common.vo.SuccessVo;
import com.mmm.order.entity.Express;
import com.mmm.order.service.ExpressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @email 1067559930@qq.com
 * @author: One
 * @date: 2022/03/10
 * @time: 18:25
 */
@RestController
@RequestMapping("/my")
public class MyExpressController {

    @Autowired
    private ExpressService expressService;

    @PostMapping("/all")
    public SuccessVo<Paging<Express>> getAll(@RequestHeader("Authorization") String token,
                                             @RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "10") Integer size) {
        return new SuccessVo<>(expressService.getMyExpressAll(token,page,size)) ;
    }

    @PostMapping("/unfinished")
    public SuccessVo<Paging<Express>> getUnfinished(@RequestHeader("Authorization") String token,
                                                    @RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "10") Integer size) {
        return new SuccessVo<>(expressService.getMyExpressUnfinished(token,page,size)) ;
    }

    @PostMapping("/finished")
    public SuccessVo<Paging<Express>> getFinished(@RequestHeader("Authorization") String token,
                                                  @RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "10") Integer size) {
        return new SuccessVo<>( expressService.getMyExpressFinish(token,page,size));
    }

    @PostMapping("/task/all")
    public SuccessVo<Paging<Express>> getTaskAll(@RequestHeader("Authorization") String token,
                                                 @RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "10") Integer size){
        return new SuccessVo<>(expressService.getTaskAll(token,page,size)) ;
    }
    @PostMapping("/task/unfinished")
    public SuccessVo<Paging<Express>> getTaskUnfinished(@RequestHeader("Authorization") String token,
                                                        @RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "10") Integer size){
        return  new SuccessVo<>(expressService.getTaskUnfinished(token,page,size)) ;
    }

    @PostMapping("/task/finished")
    public SuccessVo<Paging<Express>> getTaskFinished(@RequestHeader("Authorization") String token,
                                           @RequestParam(defaultValue = "0")Integer page,@RequestParam(defaultValue = "10") Integer size){
        return new SuccessVo<>(expressService.getTaskFinished(token,page,size));
    }
}
